<?php
session_start( );
?>
<?php
if (!isset($_SESSION['verifyUser'])) {
header("location: main.php");
}
if ($_SESSION['verifyUser'] < 3 ) {
header("location: main.php");
}

require_once('connections/mysqlDB.php');
require('smarty_connect.php');
$smarty = new smarty_connect;
$dbConn = new mysqli(HOST,USER,PWD,DB);
$dbConn->query("SET NAMES 'utf8'");
//echo $_SESSION['verifyUser'];
//var_dump($_POST);
if (isset($_POST['Submit2'])) {
header("location: reports.php");
}

if (isset($_POST['Submit'])) {
$rid=trim($_POST['rid']);
$first=trim($_POST['firstname']);
$last=trim($_POST['lastname']);

if (($first <>"") and ($last<>"")) {
$stmt1 = $dbConn->query("select b.rid, b.pastoral_staff as 'pastor', b.cname, b.first_name, b.last_name, d.description as 'state', a.country, a.home_phone  from registrant a, registration_info b, registration c, code d  
where (lower(b.first_name) like \"%$first%\" or lower(b.last_name) like \"%$last%\" ) and a.regid = c.regid and b.rid = c.rid and a.state = d.abbrev" );
$data1=array();
while ($row = $stmt1->fetch_assoc()) {
$data1[]=$row;
};
var_dump($data1);
$stmt1->close();
$smarty->assign("nflag",'Y');
$smarty->assign("data1",$data1);
}

if ($rid >= 10000){
//echo "rid=$rid";
$stmt1 = $dbConn->query("select date_format(create_date,'%m/%d/%Y') as create_date from registration where rid= $rid");
$data=array();
while ($row = $stmt1->fetch_assoc()) {
$create_date=$row['create_date'];
};
$stmt1->close();

$stmt1 = $dbConn->query("select cname,first_name,last_name,first_time,pastoral_staff,
(select description from code where abbrev = relationship) as relationship,
gender,(select description from code where abbrev = groups) as groups,
(select description from code where abbrev = special_need) as special_need,
meal1,meal2,meal3,meal4,meal5,meal6,meal7,meal8,session1,session2,
session3,session4,session5,session6,session7,session7,session8,session9,
session10,session11 
from registration_info where rid= $rid");
$data=array();
while ($row = $stmt1->fetch_assoc()) {
$data[]=$row;
};
$stmt1->close();

//var_dump($_REQUEST);
$smarty->assign("nflag","N");
$smarty->assign("regid",$regid);
$smarty->assign("rid",$rid);
$smarty->assign("create_date",$create_date);
$smarty->assign('data',$data);

} 
} else {$smarty->assign("rid", -1);}
$smarty->display('con_admin.tpl');
?>
